<?php

class myCapatchaActions extends sfActions
{

    public function preExecute()
    {
/*        ini_set('include_path',ini_get('include_path').';'.sfConfig::get('sf_plugins_dir').'/sfMyCaptchaPlugin/ext-lib');
        require('securimage.php');*/
    }
    public function executeShow_image($request)
    {
        $img = new securimage();
        
        $img->image_width = sfConfig::get('app_sfMyCaptcha_width');
        $img->image_height = sfConfig::get('app_sfMyCaptcha_height');
        $img->perturbation = sfConfig::get('app_sfMyCaptcha_perturbation');
        $img->image_bg_color = new Securimage_Color(0xf6, 0xf6, 0xf6); 
        $img->multi_text_color = array(new Securimage_Color(0x33, 0x99, 0xff),
                                       new Securimage_Color(0x33, 0, 0xcc),
                                       new Securimage_Color(0x33, 0x33, 0xcc),
                                       new Securimage_Color(0x66, 0x66, 0xff),
                                       new Securimage_Color(0x99, 0xcc, 0xcc)
                                       );
        $img->use_multi_text = sfConfig::get('app_sfMyCaptcha_use_multi_text');
        $img->text_angle_minimum = sfConfig::get('app_sfMyCaptcha_text_angle_minimum');
        $img->text_angle_maximum =  sfConfig::get('app_sfMyCaptcha_text_angle_maximum');
        $img->use_transparent_text = sfConfig::get('app_sfMyCaptcha_use_transparent_text');
        $img->text_transparency_percentage =  sfConfig::get('app_sfMyCaptcha_text_transparency_percentage');
        $img->num_lines  = sfConfig::get('app_sfMyCaptcha_num_lines');
        $img->line_color = new Securimage_Color(0xea, 0xaea, 0xea);
        $img->image_signature = sfConfig::get('app_sfMyCaptcha_image_signature');
        $img->signature_color = new Securimage_Color(rand(0, 64), rand(64, 128), rand(128, 255));
        $img->use_wordlist = sfConfig::get('app_sfMyCaptcha_use_wordlist');
        
        $img->show(); 
        
    }

    public function executePlay_sound(sfWebRequest $request)
    {
        $img    = new Securimage();
        $img->audio_format = ($request->getParameter('format') && in_array(strtolower($request->getParameter('format')), array('mp3', 'wav')) ? strtolower($request->getParameter('format')) : 'mp3');
        $img->outputAudioFile();
    }

}